<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>

<?php /** @var \Magento\PageCache\Block\System\Config\Form\Field\Export $block */
?>
<script>
require(['jquery'], function($){

    //<![CDATA[
        var fieldset = $('#system_full_page_cache_varnish'),
            fields = fieldset.find(':input:not(button)');
        if (fieldset.is(':visible') == false) {
            fieldset.show();
            fields.show();
        }
        fields.each(function (e) {
            $(this).data('previous-value', $(this).val());
        });
        fieldset.on('change', function (e) {
            var invalidFields = fields.filter(function () {
                return ($(this).val().length == 0 || ($(this).val() != $(this).data('previous-value')));
            });
            $('[id^=system_full_page_cache_varnish_export_button_version]').prop(
                'disabled',
                (invalidFields.length > 0)
            );
        });
    //]]>

});
</script>
